package com.zhangj.service.impl;

import com.zhangj.DAO.UserDAO;
import com.zhangj.pojo.User;
import com.zhangj.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName UserServiceImpl
 * @Description
 * @Author zhangjie
 * @Date 2022/1/11 18:22
 * @Version 1.0
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserDAO userDAO;

    @Override
    public List<User> findUsers() {
        return userDAO.findAll();
    }

    @Override
    public User findUserById(Long id) {
        return userDAO.getOne(id);
    }

    @Override
    public void saveUser(User user) {
        userDAO.save(user);
    }

    @Override
    public void updateUser(User user) {
        userDAO.save(user);
    }

    @Override
    public void deleteUserById(Long id) {
        userDAO.deleteById(id);
    }
}
